<?php

namespace Transaccion\Controller;

use Transaccion\Controller\GenericController;
use Componentes\Controller\UtilsArrayController;

class PensumController extends GenericController {

    public function __construct() {
        
    }

    public function get($id) {
        /*
         * Datos del pensum COMPLETO
         * Ej: http://localhost/UptaebBackend/public/transaccion/pensum/07443224
         * Rsp: {"success":true,"data":[{"salumid":"07443224","smateid":"HSBYC054202",
         * "sseccid":"HS2212","slapsid":"201421","sconmatid":"0","ssemtipins":"0"}],
         * "total":1,"mensaje":null}
         */
        $idEspecialidad = $this->params()->fromRoute('id');
        $output = $this->getPensumService()->getRegistroCompleto($idEspecialidad);
        return $this->convertirArrayAJson($output);
    }

    /**
     * Return list of resources
     * @return mixed
     */
    public function getList($id = 1, $param1 = 1, $param2 = 1, $param3 = 1) {
        $id = $this->params()->fromRoute('id');
        $param1 = $this->params()->fromRoute('param1');
        $data = null;
        $mensaje = "Defaul";
        switch ($id) {
            case (0):
                /*
                 * Datos del pensum
                 * Ej: http://localhost/UptaebBackend/public/transaccion/pensum/0/05026
                 * Rsp: {"success":true,"data":[{"salumid":"07443224","smateid":"HSBYC054202",
                 * "sseccid":"HS2212","slapsid":"201421","sconmatid":"0","ssemtipins":"0"}],
                 * "total":1,"mensaje":null}
                 */
                $idEspecialidad = $this->params()->fromRoute('param1');
                $output = $this->getPensumService()->getRegistros($idEspecialidad);
                break;
            default:
                return $param1;
        }
        return $this->convertirArrayAJson($output);
    }

    /**
     * Delete an existing resource
     * @param  mixed $id
     * @return mixed
     */
//    public function delete($id) {
//        // obtener el id del registro
//        $id = $this->params()->fromRoute('id');
//        // Eliminar el registro
//        //$alumno_service = new \Transaccion\Controller\Service\AlumnoService($this->getServiceLocator()->get('db'));
//        $pensum_service = Service\PensumService::getInstance();
//        $result = $pensum_service->deleteRegistro($id);
//        $response = $this->getResponseWithHeader();
//        $response->setContent($result);
//        return $response;
//    }

    /**
     * Update an existing resource
     * @param  mixed $id
     * @param  mixed $data
     * @return mixed
     */
//    public function updateAction() {
//        $id = $this->params()->fromRoute('id');
//        $estado = $data = (string) $this->params()->fromRoute('id2');
//        $turno = $data = (string) $this->params()->fromRoute('id3');
//        $data = array('salumestado' => $estado, 'turno' => $turno);
//        $result = $this->getPensumService()->updateRegistro($id, $data);
//        $response = $this->getResponseWithHeader();
//        $response->setContent($result);
//        return $response;
//    }

    /**
     * Create a new resource
     * @param  mixed $data
     * @return mixed
     */
//    public function create($data) {
//        $data = $this->params()->fromPost();
//        // Guardar el registro
//        $pensum_service = new Service\PensumService($this->getServiceLocator()->get('Zend\Db\Adapter'));
//        $result = $pensum_service->createRegistro($data);
//        $response = $this->getResponseWithHeader();
//        $response->setContent($result);
//        return $response;
//    }
}
